package com.ruikong.dazhi.controller.result;

import java.io.Serializable;

public class BaseResult implements Serializable {

    private Integer code;

    private String msg;

    private Object data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public  static BaseResult ok(){
        return new BaseResult(ResultApi.successCode,ResultApi.operateSuccessMsg);
    }

    public  static BaseResult ok(String msg){
        return new BaseResult(ResultApi.successCode,msg);
    }

    public  static BaseResult OK(String msg, Object data){
        BaseResult result=new BaseResult();
        result.setMsg(msg);
        result.setData(data);
        result.setCode(ResultApi.successCode);
        return result;
    }

    public  static BaseResult OK(Object data){
        BaseResult result=new BaseResult();
        result.setCode(ResultApi.successCode);
        result.setMsg(ResultApi.getSuccessMsg);
        result.setData(data);
        return result;
    }

    public BaseResult(){}

    public  BaseResult(Integer code, String msg) {
        this.code=code;
        this.msg=msg;
    }


    public static  BaseResult error(){
        return new BaseResult(ResultApi.failCode,ResultApi.getFailMsg);

    }

    public static  BaseResult error(String msg){
        return new BaseResult(ResultApi.failCode,msg);
    }

    public static BaseResult addSuccess(){
        return new BaseResult(ResultApi.successCode,ResultApi.addSuccessMsg);

    }

    public  static  BaseResult addError(){
        return new BaseResult(ResultApi.failCode,ResultApi.addFailMsg);
    }

    public static  BaseResult updateSuccess(){
        return new BaseResult(ResultApi.successCode,ResultApi.updateSuccessMsg);
    }

    public static  BaseResult updateError(){
        return new BaseResult(ResultApi.failCode,ResultApi.updateFailMsg);
    }

    public static  BaseResult deleteSuccess(){
        return new BaseResult(ResultApi.successCode,ResultApi.deleteSuccessMsg);
    }

    public static BaseResult  deleteError(){
        return new BaseResult(ResultApi.failCode,ResultApi.deleteFailMsg);
    }
}
